class: center, middle, inverse, title-slide .title[ # Skills Lab 06: Data Wrangling ] .subtitle[ ##
Straight Outta Composites
] .author[ ### Dr Danielle Evans ] .date[ ### 2 March 2022 ] --- <style type="text/css"> a { color: #f77b00; } </style> ## Overview - **Reverse Coding** + What? + Why? + How? - **Composites** + What? + Why? + How? -- <br> <br> <br> <br> .center[ ### *Let's get ready to wRangle!! (Yes, again...)* ] --- ## Reverse Coding - What & Why? - When we design questionnaires & scales we have the choice of phrasing items **positively** or **negatively** - A positively-phrased item could be: .center[ **"I love R with all of my heart."** ] - Whereas a negatively-phrased item could be: .center[ **"I hate R with every part of my being."** ] - Both Qs measure the same underlying construct, but a high score on these two items reflects opposing feelings (i.e., high like or high dislike) <br><br> <div class="mb" style="font-size:90%"> <p><b>Woah!</b> Negatively-phrased items can help reduce/identify acquiescent or careless responding on surveys - the goal is always <b>high quality data</b> 😍</p> </div> --- ## Reverse Coding - What & Why? - **Reverse coding** or **reverse scoring** is where we change the **numeric values** assigned to **negatively-phrased items** so that a **high score** reflects the same type of response across all items in our questionnaire - Let's say we have the two example items below in our questionnaire, where **strongly disagree** is scored as **1** and **strongly agree** is scored as **5**: <div style="line-height:5%;"> <br> </div> .center[ **"Q1. I really enjoy learning R in practicals."** <img src="data:image/png;base64,#img/LS3.png" width="87%" /> **"Q2. I find R soul-destroying."** <img src="data:image/png;base64,#img/LS3.png" width="87%" /> ] <div style="line-height:5%;"> <br> </div> - Assuming our participant feels consistently **positive** about **R**, then they would get a score of **5** for **Q1** & a score of **1** for **Q2** --- ## Any Questions? .center[ <iframe src="https://embed.polleverywhere.com/discourses/P7Y7y8GAGmtGTIIgEGx4v?controls=none&short_poll=true" width="100%" height="450px"></iframe> ] --- ## Reverse Coding - How? - There are multiple ways we can reverse code our variables in **R**: + If we have **numeric data**, we can use simple maths or we can use the **dplyr::recode()** function - just like in the [skills lab last week..](https://canvas.sussex.ac.uk/courses/23022/pages/week-5) + If we have **factor data**, we can use the **forcats::relevel()** function + If we have **character data**, we can use **dplyr::recode()** - We can, but we don't *need* to reverse code items before we do a **factor analysis** (FA), but we *must* reverse code negative items before we do a **reliability analysis** (RA) - We also need to reverse code items before creating **composites** - but more on that later! <div style="line-height:5%;"> <br> </div> <div class="tu" style="font-size:90%"> <p><b>Top Tip!</b> It's a good idea to reverse code items <i>after</i> running a <b>FA</b>, because items you might assume are negatively-phrased, don't always turn out to be! </p> </div> --- ## Reverse Coding - How? **Step 1: Look at the factor loadings:** .pull-left[ <table> <thead> <tr> <th style="text-align:left;background-color: #003b49; color: #fff; !important;font-size: 16px;"> Variable </th> <th style="text-align:right;background-color: #003b49; color: #fff; !important;font-size: 16px;"> MR1 </th> <th style="text-align:right;background-color: #003b49; color: #fff; !important;font-size: 16px;"> MR2 </th> <th style="text-align:right;background-color: #003b49; color: #fff; !important;font-size: 16px;"> MR3 </th> </tr> </thead> <tbody> <tr> <td style="text-align:left;background-color: #dce4e6; color: #black; !important;font-size: 16px;"> RQ6 </td> <td style="text-align:right;background-color: #dce4e6; color: #black; !important;font-size: 16px;"> 0.91 </td> <td style="text-align:right;background-color: #dce4e6; color: #black; !important;font-size: 16px;"> 0.12 </td> <td style="text-align:right;background-color: #dce4e6; color: #black; !important;font-size: 16px;"> 0.15 </td> </tr> <tr> <td style="text-align:left;background-color: #dce4e6; color: #black; !important;font-size: 16px;"> RQ8 </td> <td style="text-align:right;background-color: #dce4e6; color: #black; !important;font-size: 16px;"> 0.79 </td> <td style="text-align:right;background-color: #dce4e6; color: #black; !important;font-size: 16px;"> -0.08 </td> <td style="text-align:right;background-color: #dce4e6; color: #black; !important;font-size: 16px;"> -0.33 </td> </tr> <tr> <td style="text-align:left;background-color: #dce4e6; color: #black; !important;font-size: 16px;"> RQ7 </td> <td style="text-align:right;background-color: #dce4e6; color: #black; !important;font-size: 16px;"> 0.71 </td> <td style="text-align:right;background-color: #dce4e6; color: #black; !important;font-size: 16px;"> 0.16 </td> <td style="text-align:right;background-color: #dce4e6; color: #black; !important;font-size: 16px;"> -0.06 </td> </tr> <tr> <td style="text-align:left;background-color: #dce4e6; color: #black; !important;font-size: 16px;"> RQ5 </td> <td style="text-align:right;background-color: #dce4e6; color: #black; !important;font-size: 16px;"> -0.54 </td> <td style="text-align:right;background-color: #dce4e6; color: #black; !important;font-size: 16px;"> 0.37 </td> <td style="text-align:right;background-color: #dce4e6; color: #black; !important;font-size: 16px;"> -0.08 </td> </tr> <tr> <td style="text-align:left;background-color: #b6ccd1; color: #black; !important;font-size: 16px;"> RQ3 </td> <td style="text-align:right;background-color: #b6ccd1; color: #black; !important;font-size: 16px;"> 0.01 </td> <td style="text-align:right;background-color: #b6ccd1; color: #black; !important;font-size: 16px;"> 0.95 </td> <td style="text-align:right;background-color: #b6ccd1; color: #black; !important;font-size: 16px;"> -0.05 </td> </tr> <tr> <td style="text-align:left;background-color: #b6ccd1; color: #black; !important;font-size: 16px;"> RQ2 </td> <td style="text-align:right;background-color: #b6ccd1; color: #black; !important;font-size: 16px;"> 0.04 </td> <td style="text-align:right;background-color: #b6ccd1; color: #black; !important;font-size: 16px;"> 0.95 </td> <td style="text-align:right;background-color: #b6ccd1; color: #black; !important;font-size: 16px;"> -0.02 </td> </tr> <tr> <td style="text-align:left;background-color: #98aeb3; color: #black; !important;font-size: 16px;"> RQ9_NEG </td> <td style="text-align:right;background-color: #98aeb3; color: #black; !important;font-size: 16px;"> 0.08 </td> <td style="text-align:right;background-color: #98aeb3; color: #black; !important;font-size: 16px;"> -0.14 </td> <td style="text-align:right;background-color: #98aeb3; color: #black; !important;font-size: 16px;"> 0.95 </td> </tr> <tr> <td style="text-align:left;background-color: #98aeb3; color: #black; !important;font-size: 16px;"> RQ1_NEG </td> <td style="text-align:right;background-color: #98aeb3; color: #black; !important;font-size: 16px;"> -0.19 </td> <td style="text-align:right;background-color: #98aeb3; color: #black; !important;font-size: 16px;"> 0.01 </td> <td style="text-align:right;background-color: #98aeb3; color: #black; !important;font-size: 16px;"> 0.81 </td> </tr> <tr> <td style="text-align:left;background-color: #98aeb3; color: #black; !important;font-size: 16px;"> RQ4_NEG </td> <td style="text-align:right;background-color: #98aeb3; color: #black; !important;font-size: 16px;"> -0.35 </td> <td style="text-align:right;background-color: #98aeb3; color: #black; !important;font-size: 16px;"> -0.20 </td> <td style="text-align:right;background-color: #98aeb3; color: #black; !important;font-size: 16px;"> 0.42 </td> </tr> </tbody> </table> ] .pull-right[ <table> <thead> <tr> <th style="text-align:left;background-color: #003b49; color: #fff; !important;font-size: 16px;"> Variable </th> <th style="text-align:left;background-color: #003b49; color: #fff; !important;font-size: 16px;"> Question </th> </tr> </thead> <tbody> <tr> <td style="text-align:left;background-color: #dce4e6; color: #black; !important;font-size: 16px;"> RQ6 </td> <td style="text-align:left;background-color: #dce4e6; color: #black; !important;font-size: 16px;"> I enjoy working with computers. </td> </tr> <tr> <td style="text-align:left;background-color: #dce4e6; color: #black; !important;font-size: 16px;"> RQ8 </td> <td style="text-align:left;background-color: #dce4e6; color: #black; !important;font-size: 16px;"> I feel confident using computers. </td> </tr> <tr> <td style="text-align:left;background-color: #dce4e6; color: #black; !important;font-size: 16px;"> RQ7 </td> <td style="text-align:left;background-color: #dce4e6; color: #black; !important;font-size: 16px;"> I find computers easy to use. </td> </tr> <tr> <td style="text-align:left;background-color: #dce4e6; color: #black; !important;font-size: 16px;"> RQ5 </td> <td style="text-align:left;background-color: #dce4e6; color: #black; !important;font-size: 16px;"> I find technology challenging. </td> </tr> <tr> <td style="text-align:left;background-color: #b6ccd1; color: #black; !important;font-size: 16px;"> RQ3 </td> <td style="text-align:left;background-color: #b6ccd1; color: #black; !important;font-size: 16px;"> I love learning about statistics. </td> </tr> <tr> <td style="text-align:left;background-color: #b6ccd1; color: #black; !important;font-size: 16px;"> RQ2 </td> <td style="text-align:left;background-color: #b6ccd1; color: #black; !important;font-size: 16px;"> I like maths. </td> </tr> <tr> <td style="text-align:left;background-color: #98aeb3; color: #black; !important;font-size: 16px;"> RQ9_NEG </td> <td style="text-align:left;background-color: #98aeb3; color: #black; !important;font-size: 16px;"> I hate RStudio </td> </tr> <tr> <td style="text-align:left;background-color: #98aeb3; color: #black; !important;font-size: 16px;"> RQ1_NEG </td> <td style="text-align:left;background-color: #98aeb3; color: #black; !important;font-size: 16px;"> I dislike my R practicals. </td> </tr> <tr> <td style="text-align:left;background-color: #98aeb3; color: #black; !important;font-size: 16px;"> RQ4_NEG </td> <td style="text-align:left;background-color: #98aeb3; color: #black; !important;font-size: 16px;"> I don't enjoy using R. </td> </tr> </tbody> </table> ] <br> <div class="tu" style="font-size:90%"> <p><b>Top Tip!</b> We're looking for <b>inconsistent signs +/-</b> on the primary factor loading!</p> </div> --- ## Reverse Coding - How? **Step 2: Decide which, if any, variables are negatively related** .pull-left[ <table> <thead> <tr> <th style="text-align:left;background-color: #003b49; color: #fff; !important;font-size: 16px;"> Variable </th> <th style="text-align:right;background-color: #003b49; color: #fff; !important;font-size: 16px;"> MR1 </th> <th style="text-align:right;background-color: #003b49; color: #fff; !important;font-size: 16px;"> MR2 </th> <th style="text-align:right;background-color: #003b49; color: #fff; !important;font-size: 16px;"> MR3 </th> </tr> </thead> <tbody> <tr> <td style="text-align:left;background-color: #dce4e6; color: #black; !important;font-size: 16px;"> RQ6 </td> <td style="text-align:right;background-color: #dce4e6; color: #black; !important;font-size: 16px;"> 0.91 </td> <td style="text-align:right;background-color: #dce4e6; color: #black; !important;font-size: 16px;"> 0.12 </td> <td style="text-align:right;background-color: #dce4e6; color: #black; !important;font-size: 16px;"> 0.15 </td> </tr> <tr> <td style="text-align:left;background-color: #dce4e6; color: #black; !important;font-size: 16px;"> RQ8 </td> <td style="text-align:right;background-color: #dce4e6; color: #black; !important;font-size: 16px;"> 0.79 </td> <td style="text-align:right;background-color: #dce4e6; color: #black; !important;font-size: 16px;"> -0.08 </td> <td style="text-align:right;background-color: #dce4e6; color: #black; !important;font-size: 16px;"> -0.33 </td> </tr> <tr> <td style="text-align:left;background-color: #dce4e6; color: #black; !important;font-size: 16px;"> RQ7 </td> <td style="text-align:right;background-color: #dce4e6; color: #black; !important;font-size: 16px;"> 0.71 </td> <td style="text-align:right;background-color: #dce4e6; color: #black; !important;font-size: 16px;"> 0.16 </td> <td style="text-align:right;background-color: #dce4e6; color: #black; !important;font-size: 16px;"> -0.06 </td> </tr> <tr> <td style="text-align:left;background-color: #dce4e6; color: #black; !important;font-size: 16px;font-weight: bold;background-color: #dce4e6; color: #black; !important;font-size: 16px;"> RQ5 </td> <td style="text-align:right;background-color: #dce4e6; color: #black; !important;font-size: 16px;font-weight: bold;background-color: #dce4e6; color: #black; !important;font-size: 16px;"> -0.54 </td> <td style="text-align:right;background-color: #dce4e6; color: #black; !important;font-size: 16px;font-weight: bold;background-color: #dce4e6; color: #black; !important;font-size: 16px;"> 0.37 </td> <td style="text-align:right;background-color: #dce4e6; color: #black; !important;font-size: 16px;font-weight: bold;background-color: #dce4e6; color: #black; !important;font-size: 16px;"> -0.08 </td> </tr> <tr> <td style="text-align:left;background-color: #b6ccd1; color: #black; !important;font-size: 16px;"> RQ3 </td> <td style="text-align:right;background-color: #b6ccd1; color: #black; !important;font-size: 16px;"> 0.01 </td> <td style="text-align:right;background-color: #b6ccd1; color: #black; !important;font-size: 16px;"> 0.95 </td> <td style="text-align:right;background-color: #b6ccd1; color: #black; !important;font-size: 16px;"> -0.05 </td> </tr> <tr> <td style="text-align:left;background-color: #b6ccd1; color: #black; !important;font-size: 16px;"> RQ2 </td> <td style="text-align:right;background-color: #b6ccd1; color: #black; !important;font-size: 16px;"> 0.04 </td> <td style="text-align:right;background-color: #b6ccd1; color: #black; !important;font-size: 16px;"> 0.95 </td> <td style="text-align:right;background-color: #b6ccd1; color: #black; !important;font-size: 16px;"> -0.02 </td> </tr> <tr> <td style="text-align:left;background-color: #98aeb3; color: #black; !important;font-size: 16px;"> RQ9_NEG </td> <td style="text-align:right;background-color: #98aeb3; color: #black; !important;font-size: 16px;"> 0.08 </td> <td style="text-align:right;background-color: #98aeb3; color: #black; !important;font-size: 16px;"> -0.14 </td> <td style="text-align:right;background-color: #98aeb3; color: #black; !important;font-size: 16px;"> 0.95 </td> </tr> <tr> <td style="text-align:left;background-color: #98aeb3; color: #black; !important;font-size: 16px;"> RQ1_NEG </td> <td style="text-align:right;background-color: #98aeb3; color: #black; !important;font-size: 16px;"> -0.19 </td> <td style="text-align:right;background-color: #98aeb3; color: #black; !important;font-size: 16px;"> 0.01 </td> <td style="text-align:right;background-color: #98aeb3; color: #black; !important;font-size: 16px;"> 0.81 </td> </tr> <tr> <td style="text-align:left;background-color: #98aeb3; color: #black; !important;font-size: 16px;"> RQ4_NEG </td> <td style="text-align:right;background-color: #98aeb3; color: #black; !important;font-size: 16px;"> -0.35 </td> <td style="text-align:right;background-color: #98aeb3; color: #black; !important;font-size: 16px;"> -0.20 </td> <td style="text-align:right;background-color: #98aeb3; color: #black; !important;font-size: 16px;"> 0.42 </td> </tr> </tbody> </table> ] .pull-right[ <table> <thead> <tr> <th style="text-align:left;background-color: #003b49; color: #fff; !important;font-size: 16px;"> Variable </th> <th style="text-align:left;background-color: #003b49; color: #fff; !important;font-size: 16px;"> Question </th> </tr> </thead> <tbody> <tr> <td style="text-align:left;background-color: #dce4e6; color: #black; !important;font-size: 16px;"> RQ6 </td> <td style="text-align:left;background-color: #dce4e6; color: #black; !important;font-size: 16px;"> I enjoy working with computers. </td> </tr> <tr> <td style="text-align:left;background-color: #dce4e6; color: #black; !important;font-size: 16px;"> RQ8 </td> <td style="text-align:left;background-color: #dce4e6; color: #black; !important;font-size: 16px;"> I feel confident using computers. </td> </tr> <tr> <td style="text-align:left;background-color: #dce4e6; color: #black; !important;font-size: 16px;"> RQ7 </td> <td style="text-align:left;background-color: #dce4e6; color: #black; !important;font-size: 16px;"> I find computers easy to use. </td> </tr> <tr> <td style="text-align:left;background-color: #dce4e6; color: #black; !important;font-size: 16px;font-weight: bold;background-color: #dce4e6; color: #black; !important;font-size: 16px;"> RQ5 </td> <td style="text-align:left;background-color: #dce4e6; color: #black; !important;font-size: 16px;font-weight: bold;background-color: #dce4e6; color: #black; !important;font-size: 16px;"> I find technology challenging. </td> </tr> <tr> <td style="text-align:left;background-color: #b6ccd1; color: #black; !important;font-size: 16px;"> RQ3 </td> <td style="text-align:left;background-color: #b6ccd1; color: #black; !important;font-size: 16px;"> I love learning about statistics. </td> </tr> <tr> <td style="text-align:left;background-color: #b6ccd1; color: #black; !important;font-size: 16px;"> RQ2 </td> <td style="text-align:left;background-color: #b6ccd1; color: #black; !important;font-size: 16px;"> I like maths. </td> </tr> <tr> <td style="text-align:left;background-color: #98aeb3; color: #black; !important;font-size: 16px;"> RQ9_NEG </td> <td style="text-align:left;background-color: #98aeb3; color: #black; !important;font-size: 16px;"> I hate RStudio </td> </tr> <tr> <td style="text-align:left;background-color: #98aeb3; color: #black; !important;font-size: 16px;"> RQ1_NEG </td> <td style="text-align:left;background-color: #98aeb3; color: #black; !important;font-size: 16px;"> I dislike my R practicals. </td> </tr> <tr> <td style="text-align:left;background-color: #98aeb3; color: #black; !important;font-size: 16px;"> RQ4_NEG </td> <td style="text-align:left;background-color: #98aeb3; color: #black; !important;font-size: 16px;"> I don't enjoy using R. </td> </tr> </tbody> </table> ] <br> <div class="tu" style="font-size:90%"> <p><b>Top Tip!</b> We're looking for <b>inconsistent signs +/-</b> on the primary factor loading!</p> </div> --- ## Reverse Coding - How? **Step 2: Decide which, if any, variables are negatively related** .pull-left[ <table> <thead> <tr> <th style="text-align:left;background-color: #003b49; color: #fff; !important;font-size: 16px;"> Variable </th> <th style="text-align:right;background-color: #003b49; color: #fff; !important;font-size: 16px;"> MR1 </th> <th style="text-align:right;background-color: #003b49; color: #fff; !important;font-size: 16px;"> MR2 </th> <th style="text-align:right;background-color: #003b49; color: #fff; !important;font-size: 16px;"> MR3 </th> </tr> </thead> <tbody> <tr> <td style="text-align:left;background-color: #dce4e6; color: #black; !important;font-size: 16px;"> RQ6 </td> <td style="text-align:right;background-color: #dce4e6; color: #black; !important;font-size: 16px;"> 0.91 </td> <td style="text-align:right;background-color: #dce4e6; color: #black; !important;font-size: 16px;"> 0.12 </td> <td style="text-align:right;background-color: #dce4e6; color: #black; !important;font-size: 16px;"> 0.15 </td> </tr> <tr> <td style="text-align:left;background-color: #dce4e6; color: #black; !important;font-size: 16px;"> RQ8 </td> <td style="text-align:right;background-color: #dce4e6; color: #black; !important;font-size: 16px;"> 0.79 </td> <td style="text-align:right;background-color: #dce4e6; color: #black; !important;font-size: 16px;"> -0.08 </td> <td style="text-align:right;background-color: #dce4e6; color: #black; !important;font-size: 16px;"> -0.33 </td> </tr> <tr> <td style="text-align:left;background-color: #dce4e6; color: #black; !important;font-size: 16px;"> RQ7 </td> <td style="text-align:right;background-color: #dce4e6; color: #black; !important;font-size: 16px;"> 0.71 </td> <td style="text-align:right;background-color: #dce4e6; color: #black; !important;font-size: 16px;"> 0.16 </td> <td style="text-align:right;background-color: #dce4e6; color: #black; !important;font-size: 16px;"> -0.06 </td> </tr> <tr> <td style="text-align:left;background-color: #dce4e6; color: #black; !important;font-size: 16px;"> RQ5 </td> <td style="text-align:right;background-color: #dce4e6; color: #black; !important;font-size: 16px;"> -0.54 </td> <td style="text-align:right;background-color: #dce4e6; color: #black; !important;font-size: 16px;"> 0.37 </td> <td style="text-align:right;background-color: #dce4e6; color: #black; !important;font-size: 16px;"> -0.08 </td> </tr> <tr> <td style="text-align:left;background-color: #b6ccd1; color: #black; !important;font-size: 16px;"> RQ3 </td> <td style="text-align:right;background-color: #b6ccd1; color: #black; !important;font-size: 16px;"> 0.01 </td> <td style="text-align:right;background-color: #b6ccd1; color: #black; !important;font-size: 16px;"> 0.95 </td> <td style="text-align:right;background-color: #b6ccd1; color: #black; !important;font-size: 16px;"> -0.05 </td> </tr> <tr> <td style="text-align:left;background-color: #b6ccd1; color: #black; !important;font-size: 16px;"> RQ2 </td> <td style="text-align:right;background-color: #b6ccd1; color: #black; !important;font-size: 16px;"> 0.04 </td> <td style="text-align:right;background-color: #b6ccd1; color: #black; !important;font-size: 16px;"> 0.95 </td> <td style="text-align:right;background-color: #b6ccd1; color: #black; !important;font-size: 16px;"> -0.02 </td> </tr> <tr> <td style="text-align:left;font-weight: bold;background-color: #98aeb3; color: #black; !important;font-size: 16px;"> RQ9_NEG </td> <td style="text-align:right;font-weight: bold;background-color: #98aeb3; color: #black; !important;font-size: 16px;"> 0.08 </td> <td style="text-align:right;font-weight: bold;background-color: #98aeb3; color: #black; !important;font-size: 16px;"> -0.14 </td> <td style="text-align:right;font-weight: bold;background-color: #98aeb3; color: #black; !important;font-size: 16px;"> 0.95 </td> </tr> <tr> <td style="text-align:left;font-weight: bold;background-color: #98aeb3; color: #black; !important;font-size: 16px;"> RQ1_NEG </td> <td style="text-align:right;font-weight: bold;background-color: #98aeb3; color: #black; !important;font-size: 16px;"> -0.19 </td> <td style="text-align:right;font-weight: bold;background-color: #98aeb3; color: #black; !important;font-size: 16px;"> 0.01 </td> <td style="text-align:right;font-weight: bold;background-color: #98aeb3; color: #black; !important;font-size: 16px;"> 0.81 </td> </tr> <tr> <td style="text-align:left;font-weight: bold;background-color: #98aeb3; color: #black; !important;font-size: 16px;"> RQ4_NEG </td> <td style="text-align:right;font-weight: bold;background-color: #98aeb3; color: #black; !important;font-size: 16px;"> -0.35 </td> <td style="text-align:right;font-weight: bold;background-color: #98aeb3; color: #black; !important;font-size: 16px;"> -0.20 </td> <td style="text-align:right;font-weight: bold;background-color: #98aeb3; color: #black; !important;font-size: 16px;"> 0.42 </td> </tr> </tbody> </table> ] .pull-right[ <table> <thead> <tr> <th style="text-align:left;background-color: #003b49; color: #fff; !important;font-size: 16px;"> Variable </th> <th style="text-align:left;background-color: #003b49; color: #fff; !important;font-size: 16px;"> Question </th> </tr> </thead> <tbody> <tr> <td style="text-align:left;background-color: #dce4e6; color: #black; !important;font-size: 16px;"> RQ6 </td> <td style="text-align:left;background-color: #dce4e6; color: #black; !important;font-size: 16px;"> I enjoy working with computers. </td> </tr> <tr> <td style="text-align:left;background-color: #dce4e6; color: #black; !important;font-size: 16px;"> RQ8 </td> <td style="text-align:left;background-color: #dce4e6; color: #black; !important;font-size: 16px;"> I feel confident using computers. </td> </tr> <tr> <td style="text-align:left;background-color: #dce4e6; color: #black; !important;font-size: 16px;"> RQ7 </td> <td style="text-align:left;background-color: #dce4e6; color: #black; !important;font-size: 16px;"> I find computers easy to use. </td> </tr> <tr> <td style="text-align:left;background-color: #dce4e6; color: #black; !important;font-size: 16px;"> RQ5 </td> <td style="text-align:left;background-color: #dce4e6; color: #black; !important;font-size: 16px;"> I find technology challenging. </td> </tr> <tr> <td style="text-align:left;background-color: #b6ccd1; color: #black; !important;font-size: 16px;"> RQ3 </td> <td style="text-align:left;background-color: #b6ccd1; color: #black; !important;font-size: 16px;"> I love learning about statistics. </td> </tr> <tr> <td style="text-align:left;background-color: #b6ccd1; color: #black; !important;font-size: 16px;"> RQ2 </td> <td style="text-align:left;background-color: #b6ccd1; color: #black; !important;font-size: 16px;"> I like maths. </td> </tr> <tr> <td style="text-align:left;font-weight: bold;background-color: #98aeb3; color: #black; !important;font-size: 16px;"> RQ9_NEG </td> <td style="text-align:left;font-weight: bold;background-color: #98aeb3; color: #black; !important;font-size: 16px;"> I hate RStudio </td> </tr> <tr> <td style="text-align:left;font-weight: bold;background-color: #98aeb3; color: #black; !important;font-size: 16px;"> RQ1_NEG </td> <td style="text-align:left;font-weight: bold;background-color: #98aeb3; color: #black; !important;font-size: 16px;"> I dislike my R practicals. </td> </tr> <tr> <td style="text-align:left;font-weight: bold;background-color: #98aeb3; color: #black; !important;font-size: 16px;"> RQ4_NEG </td> <td style="text-align:left;font-weight: bold;background-color: #98aeb3; color: #black; !important;font-size: 16px;"> I don't enjoy using R. </td> </tr> </tbody> </table> ] <br> <div class="tu" style="font-size:90%"> <p><b>Top Tip!</b> We're looking for <b>inconsistent signs +/-</b> on the primary factor loading!</p> </div> --- ## Reverse Coding - How? **Step 3: Recode our items** ```r # method 1 - using simple maths on a 5-point scale data <- data %>% dplyr::mutate(column_name = 6-column_name) ``` ```r # method 2 - using recode data <- data %>% dplyr::mutate(column_name = dplyr::recode( column_name, `1` = 5, `2` = 4, `3` = 3, `4` = 2, `5` = 1)) ``` **Step 4: Check recoding** Use the table() function to compare frequencies before and after recoding to check it has worked <div style="line-height:5%;"> <br> </div> <div class="pc" style="font-size:90%"> <p><b>Demo!</b> Reverse coding numeric items & double checking with table()! </p> </div> --- ## Creating Composites - What & Why? - **Composite scores** are usually created by calculating the **mean** of a set of items from a scale or questionnaire - We can calculate composite scores from **all** items on a scale + We could have a measure of **"Love for R"** made up of all 50 survey items - Or we can create composites from different **subsets** of items that make up different **factors**/**subscales** + Maybe our measure of **"Love for R"** can be broken down into 3 **factors**/**subscales** of **"Love for Stats"**, **"Love for Computers"**, and **"Coolness"** - We look at the results of our **factor analysis** to decide how items can be combined into a composite (i.e., if we have one overall score, or different subscales), or we can use the **scoring instructions** for any pre-validated scales that we're using --- ## Creating Composites - What & Why? - For example, we could have 4 items of 'r_love' that we can use to create a composite measure by calculating the **mean** of those items for each participant .center[ <table> <thead> <tr> <th style="text-align:left;background-color: #003b49; color: #fff; !important;font-size: 19px;"> ID </th> <th style="text-align:right;background-color: #003b49; color: #fff; !important;font-size: 19px;"> r_love_1 </th> <th style="text-align:right;background-color: #003b49; color: #fff; !important;font-size: 19px;"> r_love_2 </th> <th style="text-align:right;background-color: #003b49; color: #fff; !important;font-size: 19px;"> r_love_3 </th> <th style="text-align:right;background-color: #003b49; color: #fff; !important;font-size: 19px;"> r_love_4 </th> <th style="text-align:right;background-color: #003b49; color: #fff; !important;font-size: 19px;"> r_love_comp </th> </tr> </thead> <tbody> <tr> <td style="text-align:left;background-color: #dce4e6; color: #black; !important;font-size: 19px;"> ppt1 </td> <td style="text-align:right;background-color: #dce4e6; color: #black; !important;font-size: 19px;"> 1 </td> <td style="text-align:right;background-color: #dce4e6; color: #black; !important;font-size: 19px;"> 2 </td> <td style="text-align:right;background-color: #dce4e6; color: #black; !important;font-size: 19px;"> 3 </td> <td style="text-align:right;background-color: #dce4e6; color: #black; !important;font-size: 19px;"> 1 </td> <td style="text-align:right;background-color: #dce4e6; color: #black; !important;font-size: 19px;"> 1.75 </td> </tr> <tr> <td style="text-align:left;background-color: #dce4e6; color: #black; !important;font-size: 19px;"> ppt2 </td> <td style="text-align:right;background-color: #dce4e6; color: #black; !important;font-size: 19px;"> 2 </td> <td style="text-align:right;background-color: #dce4e6; color: #black; !important;font-size: 19px;"> 5 </td> <td style="text-align:right;background-color: #dce4e6; color: #black; !important;font-size: 19px;"> 3 </td> <td style="text-align:right;background-color: #dce4e6; color: #black; !important;font-size: 19px;"> 5 </td> <td style="text-align:right;background-color: #dce4e6; color: #black; !important;font-size: 19px;"> 3.75 </td> </tr> <tr> <td style="text-align:left;background-color: #dce4e6; color: #black; !important;font-size: 19px;"> ppt3 </td> <td style="text-align:right;background-color: #dce4e6; color: #black; !important;font-size: 19px;"> 5 </td> <td style="text-align:right;background-color: #dce4e6; color: #black; !important;font-size: 19px;"> 4 </td> <td style="text-align:right;background-color: #dce4e6; color: #black; !important;font-size: 19px;"> 4 </td> <td style="text-align:right;background-color: #dce4e6; color: #black; !important;font-size: 19px;"> 3 </td> <td style="text-align:right;background-color: #dce4e6; color: #black; !important;font-size: 19px;"> 4.00 </td> </tr> <tr> <td style="text-align:left;background-color: #dce4e6; color: #black; !important;font-size: 19px;"> ppt4 </td> <td style="text-align:right;background-color: #dce4e6; color: #black; !important;font-size: 19px;"> 3 </td> <td style="text-align:right;background-color: #dce4e6; color: #black; !important;font-size: 19px;"> 1 </td> <td style="text-align:right;background-color: #dce4e6; color: #black; !important;font-size: 19px;"> 2 </td> <td style="text-align:right;background-color: #dce4e6; color: #black; !important;font-size: 19px;"> 1 </td> <td style="text-align:right;background-color: #dce4e6; color: #black; !important;font-size: 19px;"> 1.75 </td> </tr> <tr> <td style="text-align:left;background-color: #dce4e6; color: #black; !important;font-size: 19px;"> ppt5 </td> <td style="text-align:right;background-color: #dce4e6; color: #black; !important;font-size: 19px;"> 4 </td> <td style="text-align:right;background-color: #dce4e6; color: #black; !important;font-size: 19px;"> 2 </td> <td style="text-align:right;background-color: #dce4e6; color: #black; !important;font-size: 19px;"> 5 </td> <td style="text-align:right;background-color: #dce4e6; color: #black; !important;font-size: 19px;"> 5 </td> <td style="text-align:right;background-color: #dce4e6; color: #black; !important;font-size: 19px;"> 4.00 </td> </tr> <tr> <td style="text-align:left;background-color: #dce4e6; color: #black; !important;font-size: 19px;"> ppt6 </td> <td style="text-align:right;background-color: #dce4e6; color: #black; !important;font-size: 19px;"> 2 </td> <td style="text-align:right;background-color: #dce4e6; color: #black; !important;font-size: 19px;"> 3 </td> <td style="text-align:right;background-color: #dce4e6; color: #black; !important;font-size: 19px;"> 3 </td> <td style="text-align:right;background-color: #dce4e6; color: #black; !important;font-size: 19px;"> 1 </td> <td style="text-align:right;background-color: #dce4e6; color: #black; !important;font-size: 19px;"> 2.25 </td> </tr> <tr> <td style="text-align:left;background-color: #dce4e6; color: #black; !important;font-size: 19px;"> ppt7 </td> <td style="text-align:right;background-color: #dce4e6; color: #black; !important;font-size: 19px;"> 1 </td> <td style="text-align:right;background-color: #dce4e6; color: #black; !important;font-size: 19px;"> 3 </td> <td style="text-align:right;background-color: #dce4e6; color: #black; !important;font-size: 19px;"> 1 </td> <td style="text-align:right;background-color: #dce4e6; color: #black; !important;font-size: 19px;"> 4 </td> <td style="text-align:right;background-color: #dce4e6; color: #black; !important;font-size: 19px;"> 2.25 </td> </tr> <tr> <td style="text-align:left;background-color: #dce4e6; color: #black; !important;font-size: 19px;"> ppt8 </td> <td style="text-align:right;background-color: #dce4e6; color: #black; !important;font-size: 19px;"> 2 </td> <td style="text-align:right;background-color: #dce4e6; color: #black; !important;font-size: 19px;"> 1 </td> <td style="text-align:right;background-color: #dce4e6; color: #black; !important;font-size: 19px;"> 3 </td> <td style="text-align:right;background-color: #dce4e6; color: #black; !important;font-size: 19px;"> 4 </td> <td style="text-align:right;background-color: #dce4e6; color: #black; !important;font-size: 19px;"> 2.50 </td> </tr> </tbody> </table> ] - We can then use these **composites** to represent a given construct in further analyses/models --- ## Any Questions? .center[ <iframe src="https://embed.polleverywhere.com/discourses/P7Y7y8GAGmtGTIIgEGx4v?controls=none&short_poll=true" width="100%" height="450px"></iframe> ] --- ## Creating Composites - How? - We can use a combination of different functions to create a **composite score**: + **dplyr::mutate()**, **dplyr::rowwise()**, **mean()**, **c()** & **c_across()** - Before creating composites we should also **reverse score** any negative items because the scoring differs between **positive** and **negative** items and the **mean** of them would not be accurate - We often have to make some decisions around how we choose to handle **missing data** when creating composites + I.e., whether we'll calculate the mean regardless of any missing data, whether we'll calculate it for only complete cases, or whether we'll allow *some* missing data + This is entirely up to the researcher, or the scale creator (there may be specific recommendations you need to follow for scales created by others) --- ## Creating Composites - How? ```r # method 1 - using columns next to eachother comp_scores <- data %>% dplyr::rowwise() %>% dplyr::mutate(column_name1_comp = mean(c_across(item1:item3)), column_name2_comp = mean(c_across(item4:item5))) ``` ```r # method 2 - using columns NOT next to eachother data <- data %>% dplyr::rowwise() %>% dplyr::mutate(column_name1_comp = mean(c(item1, item2, item3)), column_name2_comp = mean(c(item4, item5))) ``` ```r # method 3 - with maths data <- data %>% dplyr::mutate(column_name1_comp = (item1 + item2 + item3)/3, column_name2_comp = (item4 + item5)/2) ``` <div class="pc" style="font-size:90%"> <p><b>Demo!</b> Creating composites! </p> </div> --- ## *That's all - happy wrangling!* <br> <br> <img src="data:image/png;base64,#./img/raw.jpg" width="100%" style="display: block; margin: auto;" /> <p style="text-align:right; font-size:50%">Artwork by @allison_horst</p> .center[ [Give session feedback here!](https://forms.gle/ZyXAB7kZzUUyct9n6) 😀 ]